package com.hqyj.controller;

import com.hqyj.pojo.Classes;
import com.hqyj.pojo.Room;
import com.hqyj.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("room")
public class RoomController {
    @Autowired
    RoomService roomService;

    @RequestMapping("roomList")
    public String roomList(){return "room/roomList";}

    @RequestMapping("select")
    @ResponseBody
    public HashMap<String,Object>  select(Room room){
        return roomService.select(room);
    }

    @RequestMapping("delete")
    @ResponseBody
    public HashMap<String,Object> delete(Long id){
        return roomService.delete(id);
    }

    @RequestMapping("findClasses")
    @ResponseBody
    public List<Classes> findClasses(){
        return roomService.findClasses();
    }

    @RequestMapping("insert")
    @ResponseBody
    public HashMap<String,Object> insert(Room room){
        return roomService.insertNew(room);
    }


    @RequestMapping("update")
    @ResponseBody
    public HashMap<String,Object> update(Room room){
        return roomService.update(room);
    }
}
